package action.page;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import bean.Operation;

/*
 * 主页
 */
public class Home {
	public String execute() {
		// 得到HttpSession方法
		HttpSession session = ServletActionContext.getRequest().getSession();
		// 得到HttpServletRequest方法
		HttpServletRequest request = ServletActionContext.getRequest();
	
		// 判断用户是否登录
		if ("true".equals(session.getAttribute("login"))) {
			// 若已登陆成功，则在request对象中添加username键及值
			request.setAttribute("username", (String) session.getAttribute("username"));
						
			request.setAttribute("login", "true");
		} else {
			request.setAttribute("login", "false");
		}
		return "home";
	}
}
